package com.snow.vpnclient.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author liufq
 * @since 2022-11-28 20:01:56
 */
public class DateUtils {

    public static final String FORMAT_DEFAULT = "yyyy-MM-dd HH:mm:ss";

    public static final String FORMAT_MINUTE = "yyyy-MM-dd HH:mm";

    /**
     * 是否超过7天
     */
    public static boolean isExpires(Long expireTime, int expires) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        cal.add(Calendar.DATE, -expires);
        return cal.getTimeInMillis() > expireTime;
    }

    public static String format(Date data) {
        return format(data, FORMAT_DEFAULT);
    }

    public static String format(Date data, String format) {
        return new SimpleDateFormat(format).format(data);
    }
}
